package com.he.DesignPatterns.observer;

/**
 * @description: TODO
 * @Author: HCL
 * @Date: 2024/9/4 10:39
 */
public class Client {

    public static void main(String[] args) {
        //1 创建公众号
        SubscriptionSubject subject = new SubscriptionSubject();

        //2 添加订阅者
        subject.attach(new WeiXinUser("张三"));
        subject.attach(new WeiXinUser("李四"));
        subject.attach(new WeiXinUser("王五"));
        subject.attach(new WeiXinUser("赵六"));

        //3 更新消息
        subject.notify("欢迎大家第一次来公众号");

        System.out.println("===============");

        //4 删除订阅者
        subject.detach("王五");

        //5 再更新消息
        subject.notify("公众号第二次更新了！");
    }
}
